/*
-----------------------------------------------------------------------------
This source file is part of DIVA
The project of Engineering Lab, dept. of CSIE, NTNU.

Copyright (c) 2000-2006 The Engineering Lab, dept. of CSIE, NTNU.
-----------------------------------------------------------------------------
Filename:    DIVA_FrameListener.h
Date:	2007/03/27
Description: This class contains main loop of DIVA,
			 accurately speak,OgreRoot will drive the frameStarted() in a loop after calling Root->StartRandering
				we list the steps here:
					1.Root->addFrameListener(FrameListener);
					2.Root->startRandering();
					3.(root infiniately notified FrameListener)
-----------------------------------------------------------------------------
*/

#ifndef __DIVA_FrameListener_H__
#define __DIVA_FrameListener_H__

#include "Ogre.h"
#include "OgreConfigFile.h"

class DIVA_FrameListener: public Ogre::FrameListener{
#define MINSPEED .150f
#define MOVESPEED 150 * 3
#define MAXSPEED 1.800f
public:
    // Constructor takes a RenderWindow because it uses that to determine input context
    DIVA_FrameListener(Ogre::SceneManager* mgr, Ogre::RenderWindow* win, Ogre::Camera* cam);
    ~DIVA_FrameListener();
    /** The FrameListener's start method */
    bool frameStarted(const Ogre::FrameEvent&);
	/** The FrameListener's end method */
    bool frameEnded(const Ogre::FrameEvent&);
	void switchFrameListener( bool turnedOn );

	bool frameRenderingQueued(const Ogre::FrameEvent& evt);

protected:

    Ogre::Camera* mCamera;
    Ogre::RenderWindow* mWindow;
	Ogre::SceneManager* mSceneMgr;           // A pointer to the scene manager
	
    int mSkipCount;		//how many flames after last update
    int mUpdateFreq;	//update every ### frames.
	Ogre::String str;         //store background info

	Ogre::Vector3 mTranslateVector;
	/*CEGUI copyed from sample file - compositer*/    

	Ogre::Vector3 mCenterPosition;	// save the center position of render window

    /* DEPRECATE CEGUI
	CEGUI::PushButton* stepButton;
	CEGUI::PushButton* nextButton;
	CEGUI::PushButton* contButton;
	CEGUI::PushButton* onlineButton;
	CEGUI::PushButton* chgbgButton;
	CEGUI::PushButton* newVMButton;
	CEGUI::PushButton* animationButton;
	bool handleStep(const CEGUI::EventArgs& e);
	bool handleNext(const CEGUI::EventArgs& e);
	bool handleCont(const CEGUI::EventArgs& e);
	bool handleOnline(const CEGUI::EventArgs& e);
	bool handleChgbg(const CEGUI::EventArgs& e);
	bool handleNewVM(const CEGUI::EventArgs& e);
	bool handleAnimation(const CEGUI::EventArgs& e);
	void setupEventHandlers(void);
	*/
	
	bool _firsttime ;
	bool _isTurnedOn;
};

#endif
